#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

struct TreeNode {
    int val;
    struct TreeNode* left;
    struct TreeNode* right;
};

int TreeSize(struct TreeNode* root)
{
    return root == NULL ? 0 : (TreeSize(root->left) + TreeSize(root->right) + 1);
}
void _inorderTraversal(struct TreeNode* root, int* a, int* pi)
{
    if (root == NULL)
        return;
    _inorderTraversal(root->left, a, pi);
    a[(*pi)++] = root->val;
    _inorderTraversal(root->right, a, pi);
}
int* inorderTraversal(struct TreeNode* root, int* returnSize)
{
    int size = TreeSize(root);
    int* a = (int*)malloc(sizeof(int) * size);
    int i = 0;
    _inorderTraversal(root, a, &i);
    *returnSize = size;
    return a;
}